package com.mark.service.impl;

import com.mark.entity.school.USchool;
import com.mark.mapper.USchoolMapper;
import com.mark.service.USchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (USchool)表服务实现类
 *
 * @author Deng PengFei
 * @since 2021-10-27 11:17:32
 */
@Service
public class USchoolServiceImpl implements USchoolService {
    @Autowired
    private USchoolMapper uSchoolMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param schId 主键
     * @return 实例对象
     */
    @Override
    public USchool queryById(Object schId) {
        return this.uSchoolMapper.queryById(schId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<USchool> queryAllByLimit(int offset, int limit) {
        return this.uSchoolMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param uSchool 实例对象
     * @return 实例对象
     */
    @Override
    public USchool insert(USchool uSchool) {
        this.uSchoolMapper.insert(uSchool);
        return uSchool;
    }

    /**
     * 修改数据
     *
     * @param uSchool 实例对象
     * @return 实例对象
     */
    @Override
    public USchool update(USchool uSchool) {
        this.uSchoolMapper.update(uSchool);
        return this.queryById(uSchool.getSchId());
    }

    /**
     * 通过主键删除数据
     *
     * @param schId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Object schId) {
        return this.uSchoolMapper.deleteById(schId) > 0;
    }
}